package com.example.sunwendiapplication;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class PastRecords extends AppCompatActivity implements View.OnClickListener {
    ListView grade;
    DBhelper helper;
    Button btn_author;
    TextView tv_back;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.pastrecords);
        grade = (ListView) findViewById(R.id.listView2);
        btn_author=findViewById(R.id.btn_author);
        helper = new DBhelper(getApplicationContext(), null, null, 1);
        Cursor cursor = helper.query_score();
        String [] from1 = {"_id","score","time"};
        int [] to1 = {R.id.textView1,R.id.textView2,R.id.textView3};
        SimpleCursorAdapter adapter1 = new SimpleCursorAdapter(getApplicationContext(), R.layout.item_his, cursor, from1, to1);
        grade.setAdapter(adapter1);
        btn_author.setOnClickListener(this);
        tv_back = findViewById(R.id.tv_back);
        tv_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });

    }

    @Override
    public void onClick(View v) {
        if(v==btn_author){
            Intent it1=new Intent(PastRecords.this, Writer.class);
            startActivity(it1);
        }
    }

}
